import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: resolve => require(['@/views/login/login.vue'], resolve)
  },
  {
    path: '/creatQrCode',
    component: resolve => require(['@/views/login/creatQrCode.vue'], resolve)
  },
  {
    path: '/deskTop',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
	children:[
		{
		    path: 'home',
		    component: resolve => require(['@/views/deskTop/home.vue'], resolve),
		}
	]
  },
  {
    path: '/userSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'userInfo',
  		    component: resolve => require(['@/views/userSys/userInfo.vue'], resolve),
  		},
		//中奖记录
		{
		    path: 'winRecord',
		    component: resolve => require(['@/views/userSys/winRecord.vue'], resolve),
		},
		// 积分记录
		{
		    path: 'pointRecord',
		    component: resolve => require(['@/views/userSys/pointRecord.vue'], resolve),
		},
		// 地址管理
		{
		    path: 'address',
		    component: resolve => require(['@/views/userSys/address.vue'], resolve),
		},
  	]
  },
  {
    path: '/sySys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
		{
		    path: 'goodsSys',
		    component: resolve => require(['@/views/sySys/goodsSys.vue'], resolve),
		},
  		{
  		    path: 'qrList',
  		    component: resolve => require(['@/views/sySys/qrList.vue'], resolve),
  		},
		{
			path: 'pcList',
			component: resolve => require(['@/views/sySys/pcList.vue'], resolve),
		},
		// 扫码记录
		{
		    path: 'scanRecord',
		    component: resolve => require(['@/views/sySys/scanRecord.vue'], resolve),
		},
		{
		    path: 'tixianRecord',
		    component: resolve => require(['@/views/sySys/tixianRecord.vue'], resolve),
		},
  	]
  },
  // 中奖管理
  {
    path: '/winSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'list',
  		    component: resolve => require(['@/views/winSys/list.vue'], resolve),
  		},
		//中奖记录
		{
		    path: 'winRecord',
		    component: resolve => require(['@/views/winSys/winRecord.vue'], resolve),
		},
		// 描述信息
		{
		    path: 'rewardDesc',
		    component: resolve => require(['@/views/winSys/rewardDesc.vue'], resolve),
		},
		// 提现描述
		{
		    path: 'tixianDesc',
		    component: resolve => require(['@/views/winSys/tixianDesc.vue'], resolve),
		},
		// 积分说明
		{
		    path: 'pointDesc',
		    component: resolve => require(['@/views/winSys/pointDesc.vue'], resolve),
		},
  	]
  },
  // 订单管理
  {
    path: '/orderSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'list',
  		    component: resolve => require(['@/views/orderSys/list.vue'], resolve),
  		},
		// 积分订单列表
		{
		    path: 'jifenList',
		    component: resolve => require(['@/views/orderSys/jifenList.vue'], resolve),
		}
  	]
  },
  // 积分管理
  {
    path: '/jifenSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
		{
		    path: 'jfwhter',
		    component: resolve => require(['@/views/jifenSys/jfwhter.vue'], resolve),
		},
		// 合作商积分管理
		{
		    path: 'jfwhterHzs',
		    component: resolve => require(['@/views/jifenSys/jfwhterHzs.vue'], resolve),
		}
  	]
  },
  {
    path: '/setSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'set',
  		    component: resolve => require(['@/views/setSys/set.vue'], resolve),
  		},
		{
		    path: 'myCenter',
		    component: resolve => require(['@/views/setSys/myCenter.vue'], resolve),
		}
  	]
  },
  // 系统管理
  {
    path: '/system',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
		{
		    path: 'admin',
		    component: resolve => require(['@/views/system/admin.vue'], resolve),
		},
		{
		    path: 'adminLog',
		    component: resolve => require(['@/views/system/adminLog.vue'], resolve),
		},
		{
		    path: 'areaAuth',
		    component: resolve => require(['@/views/system/areaAuth.vue'], resolve),
		},
		{
		    path: 'menu',
		    component: resolve => require(['@/views/system/menu.vue'], resolve),
		}
  	]
  },
  
]

// 解决报错
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
// replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};




const router = new VueRouter({
  mode: 'hash',
  routes
})

export default router
